home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / cfuncs.zip / ADDAPND.C < prev    next >
C/C++ Source or Header  |  1991-09-09  |  2KB  |  101 lines

  1. #include <funcs.h>
  2. #include <conio.h>
  3. /*-----------------------------Add Append---------------------------*/
  4. /*                                    */
  5. /* DESCRIPTION: If file exists ask if the user would like to start a*/
  6. /*     new list, add to an existing one, or exit.             */
  7. /*                                                                  */
  8. /* RETURNS : 'O' if file doesn't exist or new list is chosen        */
  9. /*           'A' if append is chosen                    */
  10. /*         'X' if return is chosen                    */
  11. /*                                                                  */
  12. /* USES :  Frame, select, OnCursor, OffCursor                */
  13. /*------------------------------------------------------------------*/
  14. char AddAppend(const char *file)
  15.  
  16. {
  17.   FrameDataType Fr;
  18.   char c, retcode;
  19.   int done = 0;
  20.   char *display[4], ret;
  21.   char choices[] = "123";
  22.  
  23.   if(!FileExists(file))  return('O');
  24.  
  25.   display[0] = "  1 Start a New List       ";
  26.   display[1] = "  2 Add to an Existing List";
  27.   display[2] = "  3 Return to Main Menu    ";
  28.  
  29.   Fr.clear = 2;
  30.   Frame(&Fr);
  31.  
  32.   while (!done)
  33.     {
  34.  
  35.    /* NewClear (LIGHTGRAY, MAGENTA); */
  36.  
  37.     Fr.X = 20; Fr.Y = 2;
  38.     Fr.F = LIGHTGRAY; Fr.B = BLUE;
  39.     Fr.L = 9;  Fr.W = 41;
  40.     Fr.txt[1] = "     What Do You Wish To Do?    ";
  41.     Fr.BorderType = 1;
  42.     Frame(&Fr);
  43.  
  44.     ret = select(24, 6, 3, choices, display, LIGHTGRAY, BLUE, BLACK, LIGHTGREEN, 0, 0);
  45.  
  46.     if (ret==27)
  47.       ret = '3';
  48.  
  49.     switch (ret)
  50.       {
  51.       case '1':
  52.  
  53.         OffCursor();
  54.     Fr.X = 21;
  55.     Fr.Y = 7;
  56.     Fr.F = WHITE;
  57.     Fr.B = BROWN;
  58.     Fr.L = 5;
  59.     Fr.W = 39;
  60.     Fr.txt[0] = "  This will erase previous data.";
  61.     Fr.txt[2] = "      ARE YOU SURE?  (Y/N)";
  62.         Frame(&Fr);
  63.  
  64.         c = ' ';
  65.         while (c != 'Y' && c != 'N' )
  66.           {
  67.           c = getch();
  68.           c = toupper(c);
  69.           }
  70.  
  71.         if (c == 'Y')
  72.           {
  73.           retcode = 'O';
  74.           done++;
  75.           }
  76.  
  77.         OnCursor();
  78.         break;
  79.       case '2':
  80.         retcode = 'A';
  81.         done++;
  82.         break;
  83.       case '3':
  84.         retcode = 'X';
  85.         done++;
  86.         break;
  87.       default:
  88.         break;
  89.       }
  90.     }
  91.  
  92.     return (retcode);
  93.  
  94. }
  95. /*
  96. void main()
  97. {
  98.      AddAppend("A:INVITE.DAT");
  99. }
  100. */
  101.